
package com.jsg.sl651.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 风力等级枚举
 */
@Getter
@AllArgsConstructor
public enum WindForceLevelEnum {
    CALM(0, "无风"),
    LIGHT_AIR(1, "软风"),
    LIGHT_BREEZE(2, "轻风"),
    GENTLE_BREEZE(3, "微风"),
    MODERATE_BREEZE(4, "和风"),
    FRESH_BREEZE(5, "劲风"),
    STRONG_BREEZE(6, "强风"),
    NEAR_GALE(7, "疾风"),
    GALE(8, "大风"),
    STRONG_GALE(9, "烈风"),
    STORM(10, "狂风"),
    VIOLENT_STORM(11, "暴风"),
    HURRICANE(12, "飓风"),
    OTHER(-1,"未知");
    private final int code;
    private final String name;



    /**
     * 根据 code 获取对应的 WindForceLevelEnum
     *
     * @param code 风力等级代码
     * @return 对应的 WindForceLevelEnum
     */
    public static WindForceLevelEnum getByCode(int code) {
        for (WindForceLevelEnum level : values()) {
            if (level.getCode() == code) {
                return level;
            }
        }
        return OTHER;
    }
}